#include<cstdio>
#include<cctype>
#include<algorithm>
#define mid_a ((l+r)>>1)
#define mid_b ((now->l+now->r)>>1)
const int maxn=1e5+5;
using namespace std;
struct edge
{
	int fr,to;
	edge *nt;
	edge(){fr=to=0;nt=NULL;}
}*e[maxn];
struct stree
{
	long long l,r,mx,mi;
	stree *ls,*rs;
	stree(){l=r=mx=mi=0;ls=rs=NULL;}
}*root;
inline int get();
edge* add(int fr,int to);
stree *build(int l,int r);
void dfs(edge* now);
void search(stree *now,int l,int r);
void change(stree *now,int pos,int va);
int n,q;
long long MX,MI;
int N[maxn];
int dfn[maxn],atdfn[maxn],dfsn;
bool jud[maxn];
int main()
{
	n=get();q=get();
	for(int i=1;i<=n;i++)N[i]=get();
	for(int i=1;i<=n-1;i++)
	{
		int u=get(),v=get();
		e[u]=add(u,v);
		e[v]=add(v,u);
	}
	dfs(e[1]);
	root=build(1,n);
	for(int i=1;i<=q;i++)
	{
		char c=getchar();
		if(c=='Q')
		{
			int w=get();
			w=dfn[w];
			MX=0;MI=0x7fffffffff;
			search(root,1,w);
			long long tempa=MX,tempb=MI;
			MX=0;MI=0x7fffffffff;
			search(root,w+1,n);
			printf("%lld\n",tempa*tempb+MX*MI);
		}
		else
		{
			int s=get(),t=get();
			change(root,dfn[s],t);
		}
	}
	return 0;
}
void change(stree *now,int pos,int va)
{
	if(now->l==now->r){now->mx=now->mi=va;return;}
	else if(pos<=mid_b)change(now->ls,pos,va);
	else change(now->rs,pos,va);
	now->mx=max(now->ls->mx,now->rs->mx);
	now->mi=min(now->ls->mi,now->rs->mi);
}
void search(stree *now,int l,int r)
{
	if(now->l==l&&now->r==r)
	{
		MX=max(MX,now->mx);
		MI=min(MI,now->mi);
	}
	else if(r<=mid_b)search(now->ls,l,r);
	else if(l>mid_b)search(now->rs,l,r);
	else search(now->ls,l,mid_b),search(now->rs,mid_b+1,r);
}
stree *build(int l,int r)
{
	stree *p=new stree();
	p->l=l;p->r=r;
	if(l==r)p->mx=p->mi=N[atdfn[l]];
	else
	{
		p->ls=build(l,mid_a);
		p->rs=build(mid_a+1,r);
		p->mx=max(p->ls->mx,p->rs->mx);
		p->mi=min(p->ls->mx,p->rs->mi);
	}
	return p;
}
void dfs(edge* now)
{
	dfn[now->fr]=++dfsn;
	atdfn[dfsn]=now->fr;
	int fr=now->fr;jud[fr]=true;
	while(now!=NULL)
	{
		if(!jud[now->to])dfs(e[now->to]);
		now=now->nt;
	}
}
edge* add(int fr,int to)
{
	edge *p=new edge();
	p->fr=fr;p->to=to;
	p->nt=e[fr];
	return p;
}
inline int get()
{
	int t=0,j=1;char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')j=-1;
		c=getchar();
	}
	while(isdigit(c))
	{
		t=(t<<3)+(t<<1)+c-'0';
		c=getchar();
	}
	return j*t;
}
